$ = new Object();
xyhsoft = new Object();
xyhsoft.ajax = new Object();
xyhsoft.dom = new Object();
xyhsoft.ui = new Object();

String.prototype.getBytes = function() {    
    var cArr = this.match(/[^\x00-\xff]/ig);    
    return this.length + (cArr == null ? 0 : cArr.length);    
};  


String.prototype.trim=function()
{
     return this.replace(/(^\s*)|(\s*$)/g,"");
};

Date.parseDate = function(str)
{
	if (typeof str == 'string')
	{
		var results = str.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) *$/);
		if (results && results.length > 3)
		{
			return new Date(parseInt(delZero(results[1])), parseInt(delZero(results[2])) - 1, parseInt(delZero(results[3])));
		}

		results = str.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) +(\d{1,2}):(\d{1,2}):(\d{1,2}) *$/);
		if (results && results.length > 6)
		{
			return new Date(parseInt(delZero(results[1])), parseInt(delZero(results[2])) - 1, parseInt(delZero(results[3])), parseInt(delZero(results[4])), parseInt(delZero(results[5])), parseInt(delZero(results[6])));
		}

		results = str.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) +(\d{1,2}):(\d{1,2}):(\d{1,2})\.(\d{1,9}) *$/);
		if (results && results.length > 7)
		{
			return new Date(parseInt(delZero(results[1])), parseInt(delZero(results[2])) - 1, parseInt(delZero(results[3])), parseInt(delZero(results[4])), parseInt(delZero(results[5])), parseInt(delZero(results[6])), parseInt(delZero(results[7])));
		}
		
		results = str.match(/^ *(\d{4})\/(\d{1,2})\/(\d{1,2}) *$/);
		if (results && results.length > 3)
		{
			return new Date(parseInt(delZero(results[1])), parseInt(delZero(results[2])) - 1, parseInt(delZero(results[3])));
		}

		results = str.match(/^ *(\d{4})\/(\d{1,2})\/(\d{1,2}) +(\d{1,2}):(\d{1,2}):(\d{1,2}) *$/);
		if (results && results.length > 6)
		{
			return new Date(parseInt(delZero(results[1])), parseInt(delZero(results[2])) - 1, parseInt(delZero(results[3])), parseInt(delZero(results[4])), parseInt(delZero(results[5])), parseInt(delZero(results[6])));
		}

		results = str.match(/^ *(\d{4})\/(\d{1,2})\/(\d{1,2}) +(\d{1,2}):(\d{1,2}):(\d{1,2})\.(\d{1,9}) *$/);
		if (results && results.length > 7)
		{
			return new Date(parseInt(delZero(results[1])), parseInt(delZero(results[2])) - 1, parseInt(delZero(results[3])), parseInt(delZero(results[4])), parseInt(delZero(results[5])), parseInt(delZero(results[6])), parseInt(delZero(results[7])));
		}
	}
	return null;
}
function delZero(str){
	  if(str.charAt(0) == '0'){
		return str.substring(1);  
	  }	
	  return str;
	}

Date.compare = function(srcDate, dstDate)
{
	return srcDate > dstDate;
};
Date.prototype.compareTo = function(date)
{
	return this > date;
};
Date.prototype.formatDate = function(fmt)
{

	var o =
	{
		"M+" : this.getMonth() + 1, // 月份
		"d+" : this.getDate(), // 日
		"h+" : this.getHours() % 12 == 0 ? 12 : this.getHours() % 12, // 小时
		"H+" : this.getHours(), // 小时
		"m+" : this.getMinutes(), // 分
		"s+" : this.getSeconds(), // 秒
		"q+" : Math.floor((this.getMonth() + 3) / 3), // 季度
		"S" : this.getMilliseconds()
	// 毫秒
	};
	var week =
	{
		"0" : "\u65e5",
		"1" : "\u4e00",
		"2" : "\u4e8c",
		"3" : "\u4e09",
		"4" : "\u56db",
		"5" : "\u4e94",
		"6" : "\u516d"
	};
	if (/(y+)/.test(fmt))
	{
		fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
	}
	if (/(E+)/.test(fmt))
	{
		fmt = fmt.replace(RegExp.$1, ((RegExp.$1.length > 1) ? (RegExp.$1.length > 2 ? "\u661f\u671f" : "\u5468") : "") + week[this.getDay() + ""]);
	}
	for ( var k in o)
	{
		if (new RegExp("(" + k + ")").test(fmt))
		{
			fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));

		}
	}
	return fmt;
};


function StringBuilder()
{
	this._element_ = new Array();
};
StringBuilder.prototype.append = function(item)
{
	this._element_.push(item);
};
StringBuilder.prototype.toString = function()
{
	return this._element_.join("");
};
StringBuilder.prototype.join = function(separator)
{
	return this._element_.join(separator);
};
StringBuilder.prototype.length = function()
{
	return this._element_.length;
};

Function.createCallback = function Function$createCallback(method, context)
{
	return function()
	{
		var l = arguments.length;
		if (l > 0)
		{
			var args = [];
			for ( var i = 0; i < l; i++)
			{
				args[i] = arguments[i];
			}
			;
			args[l] = context;
			return method.apply(this, args);
		}
		;
		return method.call(this, context);
	};
};

Function.createDelegate = function Function$createDelegate(instance, method)
{
	return function()
	{
		return method.apply(instance, arguments);
	};
};

if (window.HTMLElement)
{
	HTMLElement.prototype.contains = function(obj)
	{
		if (obj == this)
			return true;
		while (obj = obj.parentNode)
			if (obj == this)
				return true;
		return false;
	};
};


$Eval = xyhsoft.dom.Eval = function(element, html)
{
	element.innerHTML = html;
	var scripts = element.getElementsByTagName("script");
	var length = scripts.length;

	for ( var s = 0; s < length; s++)
	{
		var script = document.createElement("script");
		script.id = "script" + s;
		script.setAttribute("type", "text/javascript");
		if ((scripts[s].src))
		{
			script.src = scripts[s].src;
		}
		;
		if ((scripts[s].text))
		{
			script.text = scripts[s].text;
		}
		;
		document.getElementsByTagName("head")[0].appendChild(script);
	}
	;
	if (window.Page_Load)
	{
		Page_Load();
	}
};





function XMLoader() {   
    this.XMLDOMObj = arguments.callee.getXMLDOM();   
}   
if (window.ActiveXObject) {   
    XMLoader.prototype.load =function (filePath,ready,async) {   
        this.XMLDOMObj.async = async;   
        this.XMLDOMObj.load(filePath);   
        this.XMLDOMObj.onreadystatechange = function () {   
            if (this.XMLDOMObj.readyState==4) {   
                ready(this.XMLDOMObj);   
            }   
        };   
        return this.XMLDOMObj;   
    };   
    XMLoader.prototype.loadXML =function (strXML) {   
        this.XMLDOMObj.loadXML(strXML);   
        return this.XMLDOMObj;   
    };   
    XMLoader.prototype.getXML = function () {   
        return this.XMLDOMObj.xml;   
    };   
    XMLoader.getXMLDOM = function () {   
        var xmlDomVers = [   
        "Microsoft.XmlDom",   
        "MSXML2.DOMDocument",   
        "MSXML2.DOMDocument.3.0",   
        "MSXML2.DOMDocument.4.0",   
        "MSXML2.DOMDocument.5.0"  
        ];   
        for (var i=xmlDomVers.length-1;i>=0;i--) {   
            try {   
                var xmlDom = new ActiveXObject(xmlDomVers[i]);   
                return xmlDom;   
            } catch(e) {continue;}   
        }   
    };   
} else if (document.implementation && document.implementation.createDocument) {   
    XMLoader.prototype.load =function (filePath,ready,async) {   
        this.XMLDOMObj.async = async;   
        this.XMLDOMObj.load(filePath);   
        this.XMLDOMObj.onload = ready;   
        return this.XMLDOMObj;   
    };   
    XMLoader.prototype.loadXML =function (strXML) {   
        var parser = new DOMParser();   
        var xmlDom = parser.parseFromString(strXML,"text/xml");   
        while (this.XMLDOMObj.firstChild) {   
            this.XMLDOMObj.removeChild(this.XMLDOMObj.firstChild);   
        }   
        var newNode;   
        for (var i=0,len=xmlDom.childNodes.length;i< len;i++) {   
            newNode = this.XMLDOMObj.importNode(xmlDom.childNodes[i],true);   
            // importNode方法用于将其它document中的节点导入当前的document
            // 第一个参数是要导入的节点,第二个参数表示是否克隆子节点,true表示是
            this.XMLDOMObj.appendChild(newNode);   
        }   
        return this.XMLDOMObj;   
    };   
    XMLoader.prototype.getXML = function () {   
        var serializer = new XMLSerializer();   
        return serializer.serializeToString(this.XMLDOMObj,"text/xml");   
    };   
    XMLoader.getXMLDOM = function () {   
        return document.implementation.createDocument("","",null);   
    };   
} else {   
    throw new Error("对不起,您的浏览器不支持XML DOM!");   
}  


$XmlDocment = function XmlDom(xml) {
	var xmlDocument;
    if (!window.DOMParser) {
        var progIDs = [ 'Msxml2.DOMDocument.3.0', 'Msxml2.DOMDocument' ];
        for (var i = 0, l = progIDs.length; i < l; i++) {
            try {
            	xmlDocument = new ActiveXObject(progIDs[i]);
            	xmlDocument.async = false;
            }
            catch (ex) {
            }
        }
    }   
    else
    {
    	XMLDocument.prototype.loadXML=function (xml){
    		var childNodes = this.childNodes;
            for (var i = childNodes.length - 1; i >= 0; i--)
            {
                this.removeChild(childNodes[i]);
            }
            var dp = new DOMParser();
            var newDOM = dp.parseFromString(xml, "text/xml");
            var newElt = this.importNode(newDOM.documentElement, true);
            this.appendChild(newElt);   		 
    	};    	
    	xmlDocument = document.implementation.createDocument("", "xmlDOM", null);    	
    }
    
    return xmlDocument;
    
   
};

$XslProcessor=function XslProcessor()
{
	var xsltProcessor=null;	
	if (!window.XSLTProcessor)
	{
		xsltProcessor=new XmlDom();
	}
	else
	{		
		XSLTProcessor.prototype.loadXML=function (xml){
    		var childNodes = this.childNodes;
            for (var i = childNodes.length - 1; i >= 0; i--)
            {
                this.removeChild(childNodes[i]);
            }
            var dp = new DOMParser();
            var newDOM = dp.parseFromString(xml, "text/xml");
            var newElt = this.importNode(newDOM.documentElement, true);
            this.appendChild(newElt);   		 
    	}; 
    	XSLTProcessor.prototype.load=function (url){
    		var xmlHttp=new $WebRequest(url,null,function (result){this.importStylesheet(result)});
			xmlHttp.Start();	 
    	}; 
    	XSLTProcessor.prototype.transformNode=function (xmlDocument){
    		var retval = xsltProcessor.transformToDocument(xmlDocument);
			return (new XMLSerializer()).serializeToString(retval);
    	}; 
    	
		xsltProcessor=new XSLTProcessor();
	}	
	return xsltProcessor;	
};




$WebRequest = xyhsoft.ajax.WebRequest = function(url, body, onSuccess, onError,isShowLoading,loadHandleId,onShowLoading,onHideLoading)
{
   
	this.Url = url;
	this.Method = "Post";
	this.Body = body ? body : "";
	this.Enctype;
	this.TimeOut = 0;

	this.OnSuccess = onSuccess;
	this.OnError = onError;
	this.OnTimeOut;
	this.loadHandleId=loadHandleId?$get(loadHandleId):document.body;	

	if (!window.XMLHttpRequest)
		window.XMLHttpRequest = function()
		{
			var progIDs = [ "Msxml2.XMLHTTP.4.0", "Msxml2.XMLHTTP", "Microsoft.XMLHTTP" ];
			for ( var i = 0; i < progIDs.length; i++)
			{
				try
				{
					var xmlHttp = new ActiveXObject(progIDs[i]);
					return xmlHttp;

				} catch (ex)
				{
				}
				;
			}
			;
			return null;
		};

	

	this.HttpRequest = new XMLHttpRequest();

	
	this.Abort = function()
	{
		if (this.HttpRequest!=null)
		{
		   this.HttpRequest.abort();
		   this.HttpRequest = null;
		}		
	};

	this.Start = function()
	{
		this.HttpRequest.onreadystatechange = Function.createDelegate(this, this.OnReadyStateChange);
		this.HttpRequest.open(this.Method, this.Url, true);
		if (this.Method == "Post")
		{
			this.HttpRequest.setRequestHeader("Content-Type", this.Enctype ? this.Enctype : "application/x-www-form-urlencoded");// "application/x-www-form-urlencoded"application/json;charset=utf-8
		}
		this.HttpRequest.send(this.Body);
		this.showLoading();
	};
	
	this.showLoading=function ()
	{
	   if (!isShowLoading) return;
	   if (onShowLoading)
	   {
	      onShowLoading();
	      return;
	   }
	   
	   if(!this.loadHandleId)
	   {
	   	return;
	   }
	   
	   var maskLayer=$get("MaskLayer"+this.loadHandleId.id);
	   if (!maskLayer)
	   {
	      maskLayer=document.createElement("div");
	      maskLayer.className="MaskLayer";
	      maskLayer.id="MaskLayer"+this.loadHandleId.id;
	      document.body.appendChild(maskLayer);
	      
	      var objectElements=document.getElementsByTagName("object");
	      if(objectElements.length>0)
	      {
	        maskLayer.innerHTML="<iframe class='MaskIframe' frameBorder='0'/>";
	      };
	   }
	   
	   maskLayer.style.display="block";
	   
	   var loading=$get("Loading"+this.loadHandleId.id);
	   if (!loading)
	   {	
		   
	       loading=document.createElement("div");
	       loading.id="Loading"+this.loadHandleId.id;
	       loading.className="Loading";
	       var loadingText=document.createElement("div");
	       loadingText.className="LoadingText";
	       loadingText.innerHTML="正在处理中";
	       loading.appendChild(loadingText);
	       loadingText=null;
	       delete loadingText;
	       this.loadHandleId.style.position="relative";
	       this.loadHandleId.appendChild(loading);
	       
          
	   }	  
	   loading.style.display="block";
	   
	   loading=null;
       delete loading;
	   
	}
	this.hideLoading=function ()
	{
	   if (!isShowLoading) return;
	   if (onHideLoading)
	   {
	      onHideLoading();
	      return;
	   }
	   
	   if(!this.loadHandleId)
	   {
	   	return;
	   }
	  
	   var maskLayer=$get("MaskLayer"+this.loadHandleId.id);	   
	   if (maskLayer)
	   {		  
		   maskLayer.style.display="none";
	   }	   
	   var maskFrame=$get("MaskIframe"+this.loadHandleId.id);	    
	   var loading=$get("Loading"+this.loadHandleId.id);	
	   if (loading)
	   {
	      loading.style.display="none";
	   }	 	   
	}

	this.OnReadyStateChange = function()
	{
		if (this.HttpRequest.readyState == 4)
		{
		    this.hideLoading();		
			var result = this.HttpRequest.responseText;	
		
			if (this.HttpRequest.status == 200)
			{
				var contentType = this.HttpRequest.getResponseHeader("Content-Type");

				if (contentType.indexOf("application/json") > -1)
				{
					result = eval("(" + result + ")");					
				} else if (contentType.indexOf("text/xml") > -1)
				{
					result = this.HttpRequest.responseXML;
				}
				;
				if (this.OnSuccess)
				{
					this.OnSuccess(result);
				}
				;
			} else
			{
				if (this.OnError)
				{
					this.OnError(result);
				} 
				else
				{
				    if (result!="")
				    {
				       Dialog.Alert("错误提示:",result,null,500,350);
					}
				}
				;
			}
			;
			delete this.HttpRequest;
			this.HttpRequest = null;
		}
		;
	};
};

$Get = $get = xyhsoft.dom.GetElement = function(Id)
{
	return (typeof (Id) == "string" ? document.getElementById(Id) : Id);
};

$getDocument=xyhsoft.dom.getDocument=function ()
{  
   return (document.compatMode=="BackCompat"?document.body:document.documentElement) ;
};

$GetLeft = $getLeft = xyhsoft.dom.GetLeft = function(element)
{
	var left = 0;
	var src = element;
	if (src)
	{	
		while (src)
		{	
			if (src.style.position=="absolute"||src.style.position=="relative") break;
			left += src.offsetLeft-src.scrollLeft;
			src = src.offsetParent;
		}	
	}
	return left;
};

$GetTop = $getTop =  xyhsoft.dom.GetTop = function(element)
{
	var top = 0;
	var src = element;
	if (src)
	{
		top=src.scrollTop;
		while (src)
		{	
			if (src.style.position=="absolute"||src.style.position=="relative")
			{	
				break;
			}
			top += src.offsetTop-src.scrollTop ;
			src = src.offsetParent;
	   }
	}
	return top;
};
// 固定表头
$fixedHeader=xyhsoft.ui.fixedHeader=function (tableName)
{
		
	var container=null;	
	var table = $get(tableName);	
	
	if (table.offsetWidth>table.parentNode.offsetWidth)
	{
		container=table.parentNode;
	}
	
	var fixedContainer = $get(table.id+"FixedContainer");	
	if (fixedContainer)
	{
		fixedContainer.parentNode.removeChild(fixedContainer);		
	}
	var fixedContainer=document.createElement("div");
	fixedContainer.id=table.id+"FixedContainer";
	fixedContainer.style.position="absolute";
	fixedContainer.style.overflow="hidden";
	fixedContainer.style.left=$getLeft(table)-$getLeft(container?container:document.body)+"px";
	fixedContainer.style.top=$getTop(table)-$getTop(container?container:document.body)+"px";
	fixedContainer.style.width=(container?container.offsetWidth:table.offsetWidth)+"px";
	fixedContainer.style.height=table.rows[0].offsetHeight+1+"px";
	

	var fixedTable=table.cloneNode(false);
	fixedTable.id=table.id+"FixedHeader";	
	fixedTable.style.width=table.offsetWidth+"px";
	//fixedTable.style.height=table.rows[0].offsetHeight+"px";
	
	
	var tbody=document.createElement("tbody");
	fixedTable.appendChild(tbody);
	var row=table.rows[0].cloneNode(true);
	tbody.appendChild(row);	
	if (table.rows.length>1)
	{
	  // var row=table.rows[1].cloneNode(true);
	   //tbody.appendChild(row);
	}
	

	$addHandler(table,"resize",function ()
	{			
		var table = $get(tableName);	
		var fixedContainer = $get(table.id+"FixedContainer");	
		fixedTable.style.width=table.offsetWidth+"px";
		fixedTable.style.height=table.rows[0].offsetHeight+"px";
		fixedContainer.style.left=$getLeft(table)-$getLeft(container)+"px";
		//fixedContainer.style.top=$getTop(table)-$getTop(container)+"px";
		fixedContainer.style.width=table.clientWidth+"px";
		
	});
	
	fixedContainer.appendChild(fixedTable);
	
	(container?container:document.body).appendChild(fixedContainer);
};

$getObject = xyhsoft.dom.getObject = function(className)
{
	var o=null;
	try
	{	
		o=window.external.DoAppMethod(className);
	}
	catch(ex)
	{	
	}
	try
	{
		o=new ActiveXObject(className);
	}
	catch(ex)
	{	
	}
	return o;
};

$addHandler = xyhsoft.dom.AddHandler = function(element, eventName, handler)
{
	if (element.addEventListener)
	{
		element.addEventListener(eventName, handler, false);
	} else if (element.attachEvent)
	{
		element.attachEvent('on' + eventName, handler);
	}
	;
};

$removeHandler = xyhsoft.dom.RemoveHandler = function(element, eventName, handler)
{
	if (element.removeEventListener)
	{
		element.removeEventListener(eventName, handler, false);
	} else if (element.detachEvent)
	{
		element.detachEvent('on' + eventName, handler);
	}
	;
};

function SwitchTab(index)
{
	for ( var i = 0; i <= 11; i++)
	{
		if (document.getElementById("Tab" + i)&&document.getElementById("Panel" + i))
		{
			document.getElementById("Tab" + i).className = "Tab";
			document.getElementById("Panel" + i).style.display = "none";
		} 	
	}	
	if (document.getElementById("Tab" + index))
	{
		document.getElementById("Tab" + index).className = "TabActive";
		document.getElementById("Panel" + index).style.display = "block";		
	}
	
};

function RowSelect(row,name)
{
    if (!name) name="row";
	if (window[name])
	{
		window[name].className = window[name].getAttribute("oldClass");
	}
	row.className = "TableRowSelected";
	window[name] = row;	
}

function GotoUrl(frame, url)
{
	var element = $get(frame);
	if (element.getAttribute("url") != url)
	{
		ShowLoading();
		element.src = url;
		element.setAttribute("url", url);
	}
}
function ShowLoading()
{
	if ($get("Loading"))
	{
		$get("Loading").style.display = "block";
	}
}
function HideLoading()
{
	if ($get("Loading"))
	{
		$get("Loading").style.display = "none";
	}
}


// 报表展现
function bindReport(reportUrl,dataUrl,param,isPreview,loadHandleId)
{   
     
    var request = new $WebRequest(dataUrl, param, function (result) {    	   
    	getJsonResult(result,function (result){loadReport(reportUrl,result.data,isPreview);})
	},null,true,loadHandleId);
	request.Start();   
}

// 报表展现
function loadReport(reportUrl,xmlData,isPreview)
{         
     	    if (reportUrl.indexOf("http://")==-1)
    	   	{
    	        reportUrl="http://"+window.location.host+reportUrl;
    	   	}  
		    var reportViewer=$get("ReportViewer");
		   
		    if (!reportViewer)
		    {		    	
		    	reportViewer=getPrintViewer();
		    }		   
		    reportViewer.Stop();
		    var report = reportViewer.Report;
		    report.LoadFromURL(reportUrl);     
		    report.LoadDataFromXML(xmlData);
		    reportViewer.Start();  
		    if (isPreview)
		    {
		        report.PrintPreview(true);
		    } 
		    else if (isPreview==false)
		    {
		        report.Print(false);
		    }  
	   
}
// 导出excel
function exportReport(reportUrl,dataUrl,param,xlsName,loadHandleId)
{
    var request = new $WebRequest(dataUrl, param, function (result) {
    	if (reportUrl.indexOf("http://")==-1)
    	   	{
    	        reportUrl="http://"+window.location.host+reportUrl;
    	   	}
		    var reportViewer=$get("ReportViewer");

		    if (!reportViewer)
		    {
		    	reportViewer=getPrintViewer();
		    }
		    reportViewer.Stop();
		    var report = reportViewer.Report;
		    report.LoadFromURL(reportUrl);
		    report.LoadDataFromXML(result.data);
		    reportViewer.Start();
            report.ExportDirect(1,xlsName,true,true);
	},null,true,loadHandleId);
	request.Start();
}

function showRadioMenu(sender,e)
{
	var radio=sender.getElementsByTagName("input")[0];	
	if (!radio) return;
	if (!radio.checked) return;
	window.currentRadio=radio;
	var radioMenu=document.getElementById("radioMenu");
	if (!radioMenu)
	{
		radioMenu=document.createElement("div");
		radioMenu.id="radioMenu";
		radioMenu.className="PopMenu";
		radioMenu.onmousedown=function (){event.cancelBubble = true}; 
		radioMenu.onmouseover=function (){this.style.display='block'};
		radioMenu.onmouseout=function (){this.style.display='none'};
		var menuItem=document.createElement("div");
		menuItem.className="PopMenuItem";
		menuItem.innerHTML="取消选择";
		menuItem.onmouseover=function (){this.className='PopMenuItemOver';}; 
		menuItem.onmouseout=function (){this.className='PopMenuItem';};
		menuItem.onclick=function ()
		{	
			if (window.currentRadio)
			{
				window.currentRadio.checked=false;
			}
			radioMenu.style.display="none";
		};
		radioMenu.appendChild(menuItem);
		document.body.appendChild(radioMenu);
		$addHandler(document,"mousedown",function (){radioMenu.style.display="none";});
	};
	radioMenu.style.display="block";
	var left=document.documentElement.scrollLeft+$getLeft(sender);
	var top=document.documentElement.scrollTop+$getTop(sender)+sender.offsetHeight;
	if (left+radioMenu.offsetWidth>document.documentElement.offsetWidth)
	{
		left=document.documentElement.offsetWidth-radioMenu.offsetWidth;
	}
	if (top+radioMenu.offsetHeight>document.documentElement.offsetHeight)
	{
		top=top-sender.offsetHeight-radioMenu.offsetHeight;
	}	
	radioMenu.style.left=left+"px";
	radioMenu.style.top=top+"px";	
	
}



document.onkeydown = function keyDown(e)
{
    try
    {
		if (e)
		{
			event = e;
			event.srcElement = e.target;
		}
		/*
		 * if (e.altKey&&window.hotkeys[event.keyCode]) {
		 *  }
		 */
		if (event.keyCode == 13)
		{			
			if ((event.srcElement.tagName == "TEXTAREA"))
			{	
				event.cancelBubble = true;
				return true;
			}
			for ( var i = 0; i < document.forms.length; i++)
			{
				var isExit = false;
				var form = document.forms[i];
				var length=form.elements.length;
				var j = 0;
				var number=100;
				while (form.elements[j]) {
	                 var element = form.elements[j];
	                 if (event.srcElement == element) {
	                     isExit = true;
	                     break;
	                 }
	                 if (j < number) {
	                     j++;
	                 }
	                 else if (j == number) {
	                     j = length - 1;
	                 }
	                 else if (j == (number+1)) {
	                     break;
	                 }
	                 else if (j > (number+1)) {
	                     j--;
	                 }
	             }				
					
				if (isExit)
				{	
					
					var element=form.elements[j];					
					if (((element.type == "submit") || (element.type == "image") || (element.type == "button") || (element.type == "reset"))&&(element.getAttribute("skip") != "true"))
					{	
						element.focus();
						return true;
				    }				
					while (form.elements[++j])
					{	
						var element=form.elements[j];
						if (element.disabled||element.getAttribute("readonly") || (element.type == "hidden") || (element.getAttribute("skip") == "true") || (element.offsetHeight == 0))
						{
							continue;
						}
						else
						{							
							event.cancelBubble = true;
							if (element.select)
							{
								element.select();
							}							
							element.focus();							
							break;
						}
					}					
					return false;
				}
			}
		}
    }
    catch(ex)
    {
    	
    }
}



